package fo

import (
	"bufio"
	"os"
)

func WriteFile(file *os.File, content string) {
	write := bufio.NewWriter(file)
	write.WriteString(content)
	// Flush将缓存的文件真正写入到文件中
	write.Flush()
	defer file.Close()
}

func Writefile2Path(toPath string, content string) error {
	file, err := OpenFile(GetOsPath(toPath))
	if err == nil {
		WriteFile(file, content)
		return nil
	}
	return err
}
